package java12.27;

import java.sql.*;

public class Dog {


    public static void main(String[] args) throws SQLException {


        //1. 加载驱动
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        String url = "jdbc:mysql://localhost:3306/test";
        String username = "root";
        String password = "12345678";

        //2.获取一个连接
        Connection connection = DriverManager.getConnection(url, username, password);

        //3. 执行器
        String sql = "select * from user";
        Statement statement = connection.createStatement();

        ResultSet resultSet = statement.executeQuery(sql);
        while (resultSet.next()){
            int id = resultSet.getInt("id");
            String naem = resultSet.getString("name");
            int age = resultSet.getInt("age");

            System.out.println(id + "," + naem + ","  +age);
        }


        connection.close();



    }



}
